<template>
  <div class="user-info">
    <el-dropdown>
    <span class="el-dropdown-link">
      <el-avatar
        src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png">
      </el-avatar>
      <span>{{name}}</span>
      <el-icon class="el-icon--right">
        <arrow-down />
      </el-icon>
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item icon="CircleCloseFilled" @click="handleExitClick">退出登录</el-dropdown-item>
        <el-dropdown-item divided icon="User">用户信息</el-dropdown-item>
        <el-dropdown-item icon="Suitcase">系统管理</el-dropdown-item>

      </el-dropdown-menu>
    </template>
  </el-dropdown>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { useStore } from 'vuex'
import {useRouter} from 'vue-router'
import localCache from '@/utils/cache'
export default defineComponent({
  setup() {
    const store = useStore()
    const router = useRouter()
    const name = store.state.loginModule.userInfo.name
    const handleExitClick=()=>{
      localCache.deleteCache('token')
      router.push('/main')
    }
    return{
      name,
      handleExitClick
    }
  },
})
</script>


<style lang="less">
.user-info{
  cursor: pointer;
  .el-dropdown-link{
    display: flex;
    align-items: center;
  }
}
</style>